package br.com.fiap.fiappizzas.dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import br.com.fiap.fiappizzas.db.entities.Address;

public class AddressDAO extends AbstractDAO<Address> {

	public AddressDAO(Context context) {
		super(context);
	}

	@Override
	public String getTableName() {
		return "tb_address";
	}

	@Override
	public String[] getColumns() {
		return new String[]{"id", "street", "neighborhood", "city", "state", "number"};
	}

	@Override
	public Address buildEntity(Cursor cursor) {
		
		final Address a = new Address();
		
		a.setId(cursor.getLong(0));
		a.setStreet(cursor.getString(1));
		a.setNeighborhood(cursor.getString(2));
		a.setCity(cursor.getString(3));
		a.setState(cursor.getString(4));
		a.setNumber(cursor.getInt(5));
		
		return a;
		
	}

	@Override
	public ContentValues buildContentValues(Address entity) {
		
		final ContentValues values = new ContentValues();
        
		values.put("id", entity.getId());  
        values.put("street", entity.getStreet());
        values.put("neighborhood", entity.getNeighborhood());
        values.put("city", entity.getCity());
        values.put("state", entity.getState());
        values.put("number", entity.getNumber());
        
        return values;
		
	}

}
